using CustomORM.Examples.Entities;
using CustomORM.Mapping;
using FluentNHibernate.Mapping;

namespace CustomORM.Examples.MappingRepository
{
    class CustomerMapNh : ClassMap<NhCustomer>
    {
        public CustomerMapNh()
        {
            Table("Customers");
            Id(x => x.CustomerID, "`Customer ID`")
                .GeneratedBy.Assigned();
            Map(x => x.CompanyName, "`Company Name`");
            Map(x => x.ContactName, "`Contact Name`");
            Map(x => x.ContactTitle, "`Contact Title`");
            Map(x => x.City, "City");
            HasMany(x => x.Orders)
                .Access.CamelCaseField(Prefix.Underscore)
                .Fetch.Join()
                .KeyColumn("`Customer ID`");
        }
    }
}